The efficiency of `extractMax` is analogous to `insert`, determined by the heap's height.

  • Replacing the root with the last element is an $O(1)$ operation.
  • The "bubble down" process travels from the root down towards a leaf.
  • The number of swaps is at most the height of the tree.
  • A complete binary tree with $n$ nodes has a height of $O(\log n)$.

Total Complexity

The total time complexity for extractMax is dominated by the bubble down process, resulting in an overall complexity of $O(\log n)$.

Nodes (n): 1 Height (h): 0 $\log_2(n)$: 0.00